package Run_System;

import java.util.Iterator;

public class ExercisesSheet {        //用来遍历习题
    private static final  short ROW = 5;

    public static void printExercises(Iterator<Equation> iterator){         //输出算式，每行五题
        int i = 1;
        while (iterator.hasNext()){
            System.out.printf("%2d: %s\t",i,iterator.next());
            if(i % ROW == 0){
                System.out.println();
            }
            i++;
        }
        System.out.println();
    }

    public static void printExercises(Iterator<Equation> iterator, int row){     //用户指定每行多少道题
        int i = 1;
        while (iterator.hasNext()){
            System.out.printf("%2d: %s\t",i,iterator.next());
            if(i % row == 0){
                System.out.println();
            }
            i++;
        }
        System.out.println();
    }

    public static void printCaculations(Iterator<Equation> iterator){         //输出结果，每行五题
        int i = 1;
        while (iterator.hasNext()){
            System.out.printf("%2d: %3d \t",i,iterator.next().getValue());
            if(i % ROW == 0){
                System.out.println();
            }
            i++;
        }
    }

    public static void printCaculations(Iterator<Equation> iterator,int row){         //输出结果，用户指定
        int i = 1;
        while (iterator.hasNext()){
            System.out.printf("%2d: %3d \t",i,iterator.next().getValue());
            if(i % ROW == 0){
                System.out.println();
            }
            i++;
        }
    }

    public static void main(String[] args) {
        Exercises exercises = ExervisesFactory.generateExercises(1,10);
        printCaculations(exercises.iterator());
    }
}
